// intended for use on credits page

// listens for a user to click to see author's posts, then sends
// that author's name to /ajax/get_author_posts.php and returns
// what that page renders and places it in the credit page

// reduces page load time by only loading post previews on demand

function get_articles(author, random_id) {

	$('#a_'+random_id).addClass('active');

	$.ajax({
		url: "http://tastemakersmag.com/wp-content/themes/tays-t/ajax/get_author_posts.php",
		type: "POST",
		data: 'author='+author,
		dataType: "html",
		success: function(author_posts_html) {
			$('#a_'+random_id).after('<div class="author_posts_container" id="b_'+random_id+'">'+author_posts_html+'</div>');
			$('#a_'+random_id).children('p').children('a').text('hide articles');
			$('#a_'+random_id).children('p').children('a').attr('href', 'javascript:remove_articles(\''+author+'\', '+random_id+')');
			$('#a_'+random_id).removeClass('active');
		}
	});
}

// hides stories displayed by above function
function remove_articles(author, random_id) {
	
	$('#b_'+random_id).remove();
	$('#a_'+random_id).children('p').children('a').text('show articles');
	$('#a_'+random_id).children('p').children('a').attr('href', 'javascript:get_articles(\''+author+'\', '+random_id+')');
}